package com.maixy.esdemo.test;

import org.apache.http.HttpHost;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

import java.io.IOException;

/**
 * @ClassName ESTestDocGet
 * @Description TODO
 * @Date 2021/4/16 22:40
 * @Author maixy
 */
public class ESTestDocGet {
    public static void main(String[] args) throws IOException {
        RestHighLevelClient esClient =new RestHighLevelClient(
                RestClient.builder(new HttpHost("localhost",9200, "http")));

        //修改数据
        GetRequest request = new GetRequest();
        request.index("user").id("1001");

        GetResponse response = esClient.get(request, RequestOptions.DEFAULT);
        System.out.println(response.getSourceAsString());

        esClient.close();
    }
}
